package HuaweiOD;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class API集群负载统计 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        ArrayList<HashMap<String, Integer>> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            String[] strs = in.next().split("/");
            
            for(int level = 0; level < strs.length; level++){
                String str = strs[level];
                if (list.size() <= level){
                    list.add(new HashMap<>());
                }
                HashMap<String, Integer> map = list.get(level);
                map.put(str, map.getOrDefault(str, 0) + 1);
            }
        }
        
        int tar_level = in.nextInt();
        String st = in.next();
        System.out.println(list.get(tar_level).getOrDefault(st, 0));
    }
}
